<template>
    <el-table v-adaptive :data="clinicScheduleList" :border="true" :stripe="true" highlight-current-row
        @selection-change="handleSelectionChange" :header-cell-style="$headerCellStyle">
        <el-table-column :align="'center'" type="selection" width="55" />
        <el-table-column :show-overflow-tooltip="true" :align="'center'" label="所属号别" prop="clinicIndexName" />
        <el-table-column :show-overflow-tooltip="true" :align="'center'" label="出诊星期" prop="dayOfWeek">
            <template #default="scope">
                <dict-data-tag :options="dictDataMap['week_dict']" :value="scope.row.dayOfWeek" />
            </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" :align="'center'" label="出诊时段" prop="timeDesc">
            <template #default="scope">
                <dict-data-tag :options="dictDataMap['clinic_visit_schedule']"
                    :value="scope.row.timeDesc ? scope.row.timeDesc.split(',') : []" />
            </template>
        </el-table-column>
    </el-table>
    <pagination v-show="total > 0" style="margin-left: 14px;" :layout=layout v-model:limit="queryParams.pageSize"
        v-model:page="queryParams.pageNum" :pager-count="pagerCount" :total="total"
        @pagination="selectPageClinicScheduleFun" />
</template>

<script lang="ts" setup>
import { selectPageClinicSchedule } from '@/api/base/clinicSchedule'
import { useDictStoreHook } from "@/store/modules/dict";
const dictStore = useDictStoreHook();
const dictDataMap = ref(dictStore.isTypeGetData('clinic_visit_schedule', 'week_dict'))
const emits = defineEmits(['clinicScheduleTableChange'])
// 选中数组
const ids = ref([])
// 非单个禁用
const single = ref(true)
// 非多个禁用
const multiple = ref(true)
// 显示搜索条件
const showSearch = ref(true)
// 总条数
const total = ref(0)
// 出诊安排表格数据
const clinicScheduleList = ref([])
// 弹出层标题
const title = ref("")
// 是否显示弹出层
const open = ref(false)
// 列表分页功能点显示
const layout = ref("total, sizes, jumper")
// 页码按钮的数量
const pagerCount = ref(5)
// 查询参数
const queryParamsRef = ref()
const queryParams = ref<any>({
    pageNum: 1,
    pageSize: 30,
    clinicIndexId: "",
    dayOfWeek: "",
    timeDesc: "",
    limitNum: "",
    limitPreNum: "",
    orgId: "",
})
/** 父页面跳转赋值 */
function getList(parentQueryParamsInfo) {
    const parentQueryParams = parentQueryParamsInfo.value
    queryParams.value.clinicIndexId = parentQueryParams.clinicIndexId
    queryParams.value.clinicDate = parentQueryParams.clinicDate
    queryParams.value.timeDesc = parentQueryParams.timeDesc
    queryParams.value.orgId = parentQueryParams.orgId
    queryParams.value.dayOfWeek = parentQueryParams.dayOfWeek
    selectPageClinicScheduleFun()
}
/** 查询出诊安排列表 */
function selectPageClinicScheduleFun() {
    selectPageClinicSchedule(queryParams.value).then((response: any) => {
        clinicScheduleList.value = response.rows;
        total.value = response.total;
    });
}
// 多选框选中数据
function handleSelectionChange(selection) {
    ids.value = selection.map(item => item.scheduleId)
    single.value = selection.length !== 1
    multiple.value = !selection.length
    emits("clinicScheduleTableChange", selection)
}

defineExpose({
    getList
})
</script>

<script lang="ts">
export default {
    name: "clinicScheduleTable"
}
</script>

<style scoped></style>
